package com.cgs.query.monitor

import com.cgs.query.monitor.metrics.MetricsExecuteAspect
import com.sucsoft.kotlin.annotation.AllOpen
import mu.KotlinLogging
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Import

private val logger = KotlinLogging.logger { }

@AllOpen
@Configuration
@ConditionalOnExpression("\${sql.runner.monitor.enabled:true}")
@Import(MonitorController::class, MetricsExecuteAspect::class)
open class MonitorConfiguration {

    @Bean
    open fun dataSourceMonitor(): DataSourceMonitor = DataSourceMonitor()

    @Bean
    open fun projectMonitor(): ProjectMonitor = ProjectMonitor()

    @Bean
    open fun serverMonitor(): ServerMonitor = ServerMonitor()

}